package data;

import java.util.Iterator;
import java.util.Map;
import java.util.Vector;

public class Member extends User {
	private Vector<Member> _friends;
	private Boolean _activeState;
	private Vector<ForumMessageUserObject> _messages;
	
	public Member(String _name, Integer _id) {
		super(_name, _id);
		this._friends = new Vector<Member>();
		this._activeState = true;
		_messages = new Vector<ForumMessageUserObject>();
	}
	

	public Member(String name, Integer id, Vector<Member> friends, Vector<ForumMessageUserObject> messages, Boolean activeState) {
		super(name, id);
		this._friends = friends;
		this._activeState = activeState;
		this._messages = messages;
	}


	public Vector<Member> get_friends() {
		return _friends;
	}

	public Boolean get_active() {
		return _activeState;
	}

	public void set_active(Boolean _active) {
		this._activeState = _active;
	}
	
	public void addFriend(Member friend){
		if (!_friends.contains(friend))
			_friends.add(friend);
	}
	
	public void removeFriend(Member friend){
		if (_friends.contains(friend))
			_friends.remove(friend);
	}
	
	public void addMessage(Integer forumId, Integer subForumId , Integer msgId){
		_messages.add(new ForumMessageUserObject(forumId, subForumId, msgId));
	}
	
	public boolean removeMessage(Integer forumId, Integer subForumId , Integer msgId){
		for(ForumMessageUserObject it: _messages){
			if( it.get_forumId()== forumId && it.get_subForumId()== subForumId &&
					it.get_msgId()==msgId)
			{
				_messages.remove(it);
				return true;
			}
		}
		return false;
	}

}
